<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="v2/layout">
  <head>
    <title>欢迎进入管理系统</title>
    <script type="text/javascript" th:inline="javascript">
    	var type = [[${data.type}]]
    	var evaluateIds = [[${data.evaluateIds}]];
    	var pic = [[${data.pic}]];
    	var contentImg = [[${data.contentImg}]];
    	evaluateIds = eval("("+evaluateIds+")");
    	var updEvaluate = function(){
    		$.ajaxData({url:'article-evaluate',data:{evaluateIds:JSON.stringify(evaluateIds)},success:function(ret){
    			$("#evaluate").loadData({list:ret});
    		}})
    	}
    	
    	var state = getParam("state", "");
    	var evaluateLink = function(){
    		$.listAlertData({ids:evaluateIds,title:"选择",url:"/v2/evaluate/list-list",data:{size:4},cols:{"比赛":'<div class="a_eval">'+
    			'<div class="a_eval-left"><img class="a_eval-img" src="#{coverUrl}#"/></div>'+
    			'<div class="a_eval-right">'+
    				'<div class="a_eval-title"><strong>#{title}#</strong></div>'+
    				'<div class="a_eval-desc">'+
             					'<span class="a_eval-label">地点：</span>'+
             					'<span class="a_eval-text">#{area}#</span>'+
             				'</div>'+
             				'<div class="a_eval-desc">'+
             					'<span class="a_eval-label">时间：</span>'+
             					'<span class="a_eval-text">#{timeInList}#</span>'+
             				'</div>'+
            				'<div class="a_eval-desc">'+
            					'<span class="a_eval-label">主办方：</span>'+
            			'<span class="a_eval-text">#{orgName}#</span>'+
            		'</div>'+
             		'<div class="a_eval-desc">'+
             			'<span class="a_eval-label">报名费：</span>'+
             			'<span class="a_eval-text">#{charge}#</span>'+
             		'</div>'+
             	'</div>'+
           	'</div>'}, success:function(v){
           		evaluateIds = v;
           		updEvaluate();
           	}});
    	}
    	$(function(){
    		setMenu("照片墙信息");
    		
    		var validator = $("#form").jjformValidator({url:'notice-detailSave',success:function(ret){
    			location.href="zpq";
    		}});
    		validator.add("content", {min:2,max:500});
    		validator.add("title", {min:2,max:40});
    		validator.add("pic", {min:1,errorMsg:"请上传文章封面"});
    		
    		updEvaluate();
    		
    		$("#pic").jjUploadClipFile({width:120,height:80,isClip:true, url:(pic==''?null:pic)});
			var list=[];
			if(contentImg != null){
				try{
				list = eval(contentImg);
				}catch(e){}
			}
			$("#contentImg").jjUploadFile({data:list});
			$("textarea[name='content']").jjformBuilder();
    		
    		$("#listPage").page({url:"ref-list",data:{state:state}, success:function(ret){
      			$.each(ret.obj.content, function(i,v){
        			v.createdAt = new Date(v.createdAt).Format("yyyy-MM-dd HH:mm");
        		});
      			$("#list").loadData({content:ret.obj.content,orgName:orgName});
      		}});
    		
    	});
    </script>
    <style>
    </style>
  </head>
  <body>
    <div layout:fragment="content">
		<div class="info info-full">
			<div class="detail-table">
				<div class="warning">
					<i class="icon-radio"></i>
					请您遵守国家相关规定，切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容，并对所发布负责，我要学保有依据国家规定及平台规则进行处理的权利。
				</div>
				
      			<h4 class="detail-table-title">
					<i class="title-before"></i>公告信息
				</h4>
				<form id="form">
				<input type="hidden" name="id" th:value="${data.id}"/>
				<input type="hidden" name="type"  th:value="${data.type}"/>
				<div class="form">
					<div class="form-item">
						<label class="form-title">文章名称 <span class="form-required">*</span></label>
						<div class="form-content">
							<input class="form-text" type="text" name="title" placeholder="请输入文章名称（建议字数在20字以内，不超过40个字）" th:value="${data.title}"/>
							<div class="form-error" id="titleTip"></div>
						</div>
					</div>
					
					<div class="form-item">
						<label class="form-title">封面 <span class="form-required">*</span></label>
						<div class="form-content">
								<div id="pic"></div>
								<!-- <div class="upload-info">
									<button class="upload-button">选择文件</button>
									<div class="upload-text">建议尺寸750*560px或4:3,JPG、PNG格式，</div>
									<div class="upload-text">图片小于1M</div>
								</div> -->
							<div class="form-error" id="picTip"></div>
						</div>
					</div>
					
					<div class="form-item">
						<label class="form-title">图集 <span class="form-required">*</span></label>
						<div class="form-content">
								<div id="contentImg"></div>
								<!-- <div class="upload-info">
									<button class="upload-button">选择文件</button>
									<div class="upload-text">建议尺寸750*560px或4:3,JPG、PNG格式，</div>
									<div class="upload-text">图片小于1M</div>
								</div> -->
							<div class="form-error" id="contentImgTip"></div>
						</div>
					</div>
					
					<div class="form-item">
						<label class="form-title">文章详情 <span class="form-required">*</span></label>
						<div class="form-content">
							<textarea  class="form-text" rows="" cols="" name="content" th:text="${data.content}"></textarea>
							<div class="form-error" id="contentTip"></div>
						</div>
					</div>
				</div>
				
				
				<h4 class="detail-table-title">
					<i class="title-before"></i>关联信息
				</h4>
				
				<div class="form">
					<div class="form-item">
						<label class="form-title">关联比赛</label>
						<div class="form-content">
							<div class="form-desc">
								点击添加关联比赛，将文章关联到您主办的比赛中，将显示在所关联比赛主页的“新闻公告”栏目中
							</div>
							<div class="form-eval">
								<script type="text/template" id="evaluate">
								#for(data:list)#
									<div class="img">
										<div class="img-item"><img src="#{data.coverUrl}#"/ style="width: 120px;height: auto;"></div>
										<div class="img-desc" style="width: 120px;">#{data.title}#</div>
										<input type="hidden" name="evaluateIds" value="#{data.id}#"/>
									</div>
								#endfor#
								</script>
							</div>
							<div style="display: flex;">
								<span class="form-button" onclick="evaluateLink()"><span class="form-button-add">+</span>关联比赛</span>
							</div>
						</div>
					</div>
				</div>
				
				<div class="form">
					<div class="form-item">
						<label class="form-title"></label>
						<button class="form-submit">保存</button>
					</div>
				</div>
				</form>
          	</div>
			
    	</div>
    	
    </div>
  </body>
</html>